<%-- 
    Document   : index
    Created on : Sep 22, 2010, 2:58:38 PM
    Author     : M Bilal
--%>

<%@page import="wap.rockvilletech.portal.SystemProperty"%>
<%@page import="wap.rockvilletech.portal.DBProc"%>

<%@ page import="java.io.*,java.sql.*,java.net.*"%>
<%@ page import="org.apache.log4j.Logger" %>

<% final Logger log = Logger.getLogger("JSP.INDEX");%>





<%@ include file="../includes/header.jspf"%>

<%
//pagging variables
    int intBlockLength = 5, intRecordsToBeDisplayed = 0, intRecordsToBeFetched = 0, intCountTotal = 0, intPageID = 0, intLastPage = 0;
	String strPagingLinks = "", pid = "";
	boolean computePaging = false, isNext = true;
        pid = request.getParameter("pid") != null ? request.getParameter("pid") : "0";
//end pagging var
            String strThisPageName="index.jsp",nav_Extra = "";
            thisPage="index.jsp";
            String strPageTitle_thisCat=strTitle;
            String _categoryList="WALLPAPERS,ANIMATED,GAMES,THEMES,TRUETONES,VIDEOS";
            DBProc db = DBProc.getInstance();
            //--Vector vTopContent = db.getTopContent();
            Vector v_content_cat = null;
            //--HashMap hmCat = db.getContentCat();
            Vector v_cat = db.getContentCat();
            //Set setCat=hmCat.keySet();
            //Object[] objArrCat=setCat.toArray();
            

            int intContentLimit = Integer.parseInt(SystemProperty.getProperty("contentLimit"));//Display content limit
            String strContentId = "", strCategoryId = "", strImagePath = "", strMainCat = "", strSingerOrFilm = "", strContentType = "", strCatName = "", strContentName = "";


%>
<div align="center">

    <div style="background-color: #dedfe1;padding-top:2px;background-image:url('../images/new/.jpg');background-repeat: repeat-x;background-position:bottom;" title="">
        <a href="<%=context_Path%>/index.jsp"><img src='<%=context_Path%>/imgsrv?img=home<%=sImgFix%>.jpg&repo=PI&s=0&w=<%=mainButtonImgWidth%>' alt="home" title="Home"></a>
        <img src='<%=context_Path%>/imgsrv?img=downloads_selected<%=sImgFix%>.jpg&repo=PI&s=0&w=<%=mainButtonImgWidth%>' alt="downloads" title="Downloads">
        <a href="<%=context_Path%>/coolstuff/index.jsp"><img src='<%=context_Path%>/imgsrv?img=cool_stuff<%=sImgFix%>.jpg&repo=PI&s=0&w=<%=mainButtonImgWidth%>' alt="coolstuff" title="CoolStuff"></a>
        <a href="<%=context_Path%>/news/news.jsp"><img src='<%=context_Path%>/imgsrv?img=news<%=sImgFix%>.jpg&repo=PI&s=0&w=<%=mainButtonImgWidth%>' alt="news" title="News"></a>
    </div>
    
<%@include  file="../includes/navigationLinks.jspf"%>



   <div align="left" style="width:<%=width%>;text-align: left; font-weight: bold;background-color:#b2b2b2;padding:3px 0px 3px 5px;border-top:2px solid #A1A1A1;border-bottom: 2px solid #A1A1A1;">
                <%
                String css_selected="grey";
                for(int i=0;i<v_cat.size();i++){
                    css_selected = v_cat.get(i).toString().equalsIgnoreCase(app)?"orange":"grey";
                    if(i>0){
                %>
                <%-- <img alt="" src="../images/new/top_bar_02_seperator.jpg"> --%>
                    <b>&nbsp;|&nbsp;</b>
                <%}%>
                
                    <a href="<%=context_Path%>/content/index.jsp?app=<%=v_cat.get(i).toString()%>"><span class="hor-nav-<%=css_selected%>-link"><%=v_cat.get(i).toString()%></span></a>
             <%}%>
    </div>




    <div>

        <table cellpadding="0" cellspacing="0" width="100%">
            <%
            if("Bollywood".equals(app)||"Hollywood".equals(app)||"Islamic".equals(app)||"Pakistani".equals(app)||"Events".equals(app)||"Games".equals(app) ||"WorldCup2011".equals(app)){

                        v_content_cat = db.getContentCat(pid,app);
	intCountTotal = (Integer)v_content_cat.get(0);
        intRecordsToBeDisplayed = intRecordsToBeFetched = (Integer)v_content_cat.get(1);

	try {
		intLastPage = intCountTotal / intRecordsToBeDisplayed;
		intPageID = Integer.parseInt(pid);
		if (intPageID > intLastPage) {
        	intPageID = intLastPage;
        }
        if(intCountTotal == (int)(intRecordsToBeDisplayed*(intPageID+1)))
        	intLastPage--;
    } catch(NumberFormatException ex) {
    	log.warn("number format exception at content_category.jsp =" + ex.toString());
    }

    int totalCatInChannel = v_content_cat.size()-2;
	if (totalCatInChannel + 1 < intRecordsToBeFetched) {
		intRecordsToBeDisplayed -= (intRecordsToBeFetched - totalCatInChannel);
		intRecordsToBeFetched = totalCatInChannel;
        isNext = false;
	}

	computePaging = intCountTotal >intRecordsToBeDisplayed;
	//--String strThisPageRequestUrl=wap.rockvilletech.util.RequestUrlHelper.getRequest_QueryString_CurrentPage(request, strThisPageName);

            %>
            <tr>
                <td align="left" style="padding:3px 0px 0px 15px;">
                    <table bgcolor="#d5d5d5" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                            <td><img src="<%=context_Path%>/images/bar_left.png" alt="" /></td><td><%="<b> Categories </b>"%></td><td><img src="<%=context_Path%>/images/bar_right.png" alt="" /></td>
                            </tr>
                        </table>
                </td>
            </tr>
                        <tr>
                <td align="center" style="background-image:url('../images/new/catagory_top_part.jpg');background-repeat: repeat-x;">
                    <div style="padding:5px 0px 5px 0px;">
                        <%
                        //--String strAppsubcat=(String)hmCat.get(app);
                        //--String[] strAppcat = strAppsubcat.split(",");
                        if (v_content_cat.size()>2) {
                        %>
                        
                                <%
                                int category_count=0,table_counter=1;
                                if(!renderSingleColumn){
                                    %>
                             <table align="center" width="95%" cellpadding="0" cellspacing="0">
                                <%
                                }

                                String[] str_arr_cat=null;
                                for (int i = 2; i < v_content_cat.size(); i++) {
                                    str_arr_cat =(String[]) v_content_cat.get(i);
                                    strCatName = str_arr_cat[0];
                                   if ((category_count % 2) == 0 && !renderSingleColumn) {
                            if (category_count > 0) {
                            %>
                                    </tr>
                            <%}%>
                            <tr>
            <%
                            }
                            if (!renderSingleColumn) {
            %>
            <td width="50%" valign="top" align="left">
                <%                                }
                                %>
                                <a href="<%=context_Path%>/content/index.jsp?app=<%=strCatName%>&FoS=<%=strAppFOrS%>">
                                    <%=str_arr_cat[1]%>
                                </a>
                                <%
                                if(renderSingleColumn){
                                    %><br/>
                <%
                                }else{
                                        %>
                                        </td>
                <%
                                         category_count++;
                                          if (table_counter == v_content_cat.size()-2 && !renderSingleColumn) {
                                        if ((category_count % 2) != 0) {
                    %>
                    <td width="50%" valign="top">&nbsp;</td>
                    <%                     }
                    %>
   </tr> </table>
<%
                }
                                         table_counter++;

                                }
                                 }//end for loop
                                %>


                        <%
                        if (computePaging) {
			// Call the method which will generate Page links
			wap.rockvilletech.util.Paging.computePaging(request,
				"index.jsp?",
				intRecordsToBeFetched, intRecordsToBeDisplayed,
				intCountTotal, intBlockLength, intLastPage, intPageID,
				isNext);

			// Get the generated Summary and links
			strPagingLinks = wap.rockvilletech.util.Paging.getPagingLinks();
			//--out.println(strPagingLinks);
		}

                          } else {
                                     out.println("Content is not available!");
                                }
                        %>
                    </div>
                    <div align="right" style="padding-right: 3px;">
                        <%=strPagingLinks%>
                        </div>
                </td>
            </tr>

            <%
            }
           %>
         </table>
    </div>

<%@ include file="../includes/contentSection.jspf"%>
<%--
    <div style="background-color: #D6D6D6;padding:4px 0px 4px 0px;margin:6px 0px 3px 0px;font-weight: bold;">
        <a href="<%=context_Path%>/content/ContentPage.jsp?app=<%=app%>&CatID=4&CatType=TRUETONES">
            RingTones</a>
        <%--
        <span class="pipe_seprator">|</span>
        <a href="<%=context_Path%>/content/ContentPage.jsp?app=<%=app%>&CatID=5&CatType=POLYTONES&MainCat=<%=strAppMainCat%>"> Polytones</a>
         --%>
<%--
<span class="pipe_seprator">|</span> <a href="<%=context_Path%>/content/ContentPage.jsp?app=Ufone_Content&CatID=2&CatType=ANIMATED">Animations</a>
    </div>

 --%>
    <%@include file="/includes/horizontal_bottom_menu.jspf"%>
    <%@ include file="../includes/others.jspf"%>
     <div style="padding:0px 0px 0px 0px;text-decoration: underline;">
        <jsp:include page="../banner.jsp">
            <jsp:param name="w" value="<%=width%>"/>
        </jsp:include>
    </div>

     

<%@ include file="../includes/footer.jspf"%>



<%
wpb.LogVisit(strIP, thisPage, strGsm, strApn, strBrand, strModel, app, request.getQueryString());
%>